<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Used to modify the behavior of a prepared statement</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="mysqli-stmt.attr-get.html">« mysqli_stmt::attr_get</a></li>
      <li style="float: right;"><a href="mysqli-stmt.bind-param.html">mysqli_stmt::bind_param »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.mysqli-stmt.html">MySQLi_STMT</a></li>
    <li>Used to modify the behavior of a prepared statement</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="mysqli-stmt.attr-set" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">mysqli_stmt::attr_set</h1>
  <h1 class="refname">mysqli_stmt_attr_set</h1>
  <p class="verinfo">(PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">mysqli_stmt::attr_set</span> -- <span class="refname">mysqli_stmt_attr_set</span> &mdash; <span class="dc-title">Used to modify the behavior of a prepared statement</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-mysqli-stmt.attr-set-description">
  <h3 class="title">说明</h3>
  <p class="para">面向对象风格</p>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>mysqli_stmt::attr_set</strong></span>(<span class="methodparam"><span class="type">int</span> <code class="parameter">$attribute</code></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter">$value</code></span>): <span class="type">bool</span></div>

  <p class="para rdfs-comment">过程化风格</p>
  <div class="methodsynopsis dc-description"><span class="methodname"><strong>mysqli_stmt_attr_set</strong></span>(<span class="methodparam"><span class="type"><a href="class.mysqli-stmt.html" class="type mysqli_stmt">mysqli_stmt</a></span> <code class="parameter">$statement</code></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter">$attribute</code></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter">$value</code></span>): <span class="type">bool</span></div>

  <p class="para rdfs-comment">
   Used to modify the behavior of a prepared statement. This function may be
   called multiple times to set several attributes.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-mysqli-stmt.attr-set-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl><dt>

<code class="parameter">statement</code></dt>
<dd>
<p class="para">仅以过程化样式：由
<span class="function"><a href="mysqli.stmt-init.html" class="function">mysqli_stmt_init()</a></span> 返回的 <span class="classname"><a href="class.mysqli-stmt.html" class="classname">mysqli_stmt</a></span> 对象。</p></dd>

     <dt>
<code class="parameter">attribute</code></dt>

     <dd>

      <p class="para">
       The attribute that you want to set. It can have one of the following values:
       <table id="mysqli-stmt.attr-set.parameters" class="doctable table">
        <caption><strong>Attribute values</strong></caption>
        
         <thead>
          <tr>
           <th>Character</th>
           <th>Description</th>
          </tr>

         </thead>

         <tbody class="tbody">
          <tr>
           <td>MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH</td>
           <td>
            Setting to <strong><code>true</code></strong> causes <span class="function"><a href="mysqli-stmt.store-result.html" class="function">mysqli_stmt_store_result()</a></span> to
            update the metadata <code class="literal">MYSQL_FIELD-&gt;max_length</code> value.
           </td>
          </tr>

          <tr>
           <td>MYSQLI_STMT_ATTR_CURSOR_TYPE</td>
           <td>
            Type of cursor to open for statement when <span class="function"><a href="mysqli-stmt.execute.html" class="function">mysqli_stmt_execute()</a></span>
            is invoked. <code class="parameter">value</code> can be <code class="literal">MYSQLI_CURSOR_TYPE_NO_CURSOR</code>
            (the default) or <code class="literal">MYSQLI_CURSOR_TYPE_READ_ONLY</code>.
           </td>
          </tr>

          <tr>
           <td>MYSQLI_STMT_ATTR_PREFETCH_ROWS</td>
           <td>
            Number of rows to fetch from server at a time when using a cursor.
            <code class="parameter">value</code> can be in the range from 1 to the maximum
            value of unsigned long. The default is 1.
           </td>
          </tr>

         </tbody>
        
       </table>

      </p>
      <p class="para">
       If you use the <code class="literal">MYSQLI_STMT_ATTR_CURSOR_TYPE</code> option with
       <code class="literal">MYSQLI_CURSOR_TYPE_READ_ONLY</code>, a cursor is opened for the
       statement when you invoke <span class="function"><a href="mysqli-stmt.execute.html" class="function">mysqli_stmt_execute()</a></span>. If there
       is already an open cursor from a previous <span class="function"><a href="mysqli-stmt.execute.html" class="function">mysqli_stmt_execute()</a></span> call,
       it closes the cursor before opening a new one. <span class="function"><a href="mysqli-stmt.reset.html" class="function">mysqli_stmt_reset()</a></span>
       also closes any open cursor before preparing the statement for re-execution.
       <span class="function"><a href="mysqli-stmt.free-result.html" class="function">mysqli_stmt_free_result()</a></span> closes any open cursor.
      </p>
      <p class="para">
       If you open a cursor for a prepared statement, <span class="function"><a href="mysqli-stmt.store-result.html" class="function">mysqli_stmt_store_result()</a></span>
       is unnecessary.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">value</code></dt>

     <dd>

      <p class="para">The value to assign to the attribute.</p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-mysqli-stmt.attr-set-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回 <strong><code>true</code></strong>， 或者在失败时返回 <strong><code>false</code></strong>。
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-mysqli-stmt.attr-set-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><a href="http://dev.mysql.com/doc/en/mysql-stmt-attr-set.html" class="link external">&raquo;&nbsp;Connector/MySQL mysql_stmt_attr_set()</a></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>